#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int n,a[maxn],pos[maxn],tot;
int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int l=-1;
	for(int i=n;i>=1;i--)
	{
		if(a[i]!=l)
		{
			l=a[i];
			pos[i]=i;
		}
		else pos[i]=pos[i+1];
	}
//	for(int i=1;i<=n;i++)
	//	printf("%d ",pos[i]);putchar('\n');
	while(tot<n)
	{
		int t=3;
		for(int i=1;i<=n;i++)
		{
			if(a[i]==2)continue;
			if(a[i]!=t)
			{
				t=a[i];
				a[i]=2;
				printf("%d ",i);
				tot++;
				i=pos[i];
			}
		}
		printf("\n");
	}
	return 0;
}
